package repo

import (
	"context"
	"forum/internal/adapter/driving/dao"
	"forum/internal/domain"
	"forum/internal/domain/repo"
)

var _ repo.UserRepository = &UserRepositoryImp{}

type UserRepositoryImp struct {
	userDao dao.UserDao
}

func NewUserRepositoryImp(userDao dao.UserDao) *UserRepositoryImp {
	return &UserRepositoryImp{
		userDao: userDao,
	}
}
func (u *UserRepositoryImp) FindById(ctx context.Context, id int64) (domain.User, error) {
	return u.userDao.FindById(ctx, id)
}

func (u *UserRepositoryImp) Save(ctx context.Context, user domain.User) error {
	return u.userDao.Insert(ctx, user)
}

func (u *UserRepositoryImp) FindByEmail(ctx context.Context, user domain.User) (domain.User, error) {
	return u.userDao.FindByEmail(ctx, user)
}
